const childprocess = require('child_process');

exports.getShell = function (filename, options = []) {
    return childprocess.execSync(`${filename} ${options.join(' ')}`).toString();
}

exports.getDirName = function (allFileName, startFileName, sign) {
    let split = !sign ? '/' : sign;
    let dirname = [];
    let labname = '';
    let temp = allFileName.split(split);
    for (let i = 0; i < temp.length; i++) {
        if (temp[i].toLocaleLowerCase() === startFileName.toLocaleLowerCase()) {
            labname = temp[i - 1];
            break;
        } else {
            dirname.push(temp[i]);
        }
    }
    return [dirname.join(split), labname];
}